<?php

class Zendhlt_View_Helper_BirthdayElement extends Zend_View_Helper_FormElement {
	
    protected $html = '';
    
    public function birthdayElement($name, $value = null, $attribs = null) {
        $daynum = $monthnum = $yearnum = '';
        if ($value)
            list($daynum, $monthnum, $yearnum) = explode('-', $value);

        $helperSelect = new Zend_View_Helper_FormSelect();
        $helperSelect->setView($this->view);
        $helperText = new Zend_View_Helper_FormText();
        $helperText->setView($this->view);
        
    	$optionsDay = array('' => 'Ngày');
        $optionsMonth = array('' => 'Tháng');
        for ($i = 1; $i < 10; $i++) {
        	$optionsDay['0'.$i] = "$i";
        	$optionsMonth['0'.$i] = 'Tháng '.$i;
        }
        
        for ($i = 10; $i < 13; $i++) {
        	$optionsMonth[$i] = 'Tháng '.$i;
        }
        
    	for ($i = 10; $i < 32; $i++) {
        	$optionsDay[$i] = "$i";
        }

        $this->html .= $helperSelect->formSelect($name . '[daynum]', $daynum, array('class' => 'birthday'), $optionsDay);
        $this->html .= $helperSelect->formSelect($name . '[monthnum]', $monthnum, array('class' => 'birthday'), $optionsMonth);
        $this->html .= $helperText->formText($name . '[yearnum]', $yearnum, array('size' => 4,'maxlength' => 4, 'id' => $name, 'class' => 'birthday', 'onkeypress' => 'validate(event)'));
        
        return $this->html;
    }

}

